package Messages;

import jade.core.Agent;
import Agents.Messageable;
import Agents.AUser;

public class UserMessage extends AMessage
{
	public int location_x;
	public int location_y;
	public int temperature;
	public int noise;
	public int light;
	public int garbageWeight;
	public int garbageVolume;
	
	protected String constructSpecialMessage(Messageable agent) 
	{
		return ((Agent)agent).getLocalName() + AMessage.senderSplit + 
				AMessage.unitsSplit + AMessage.Units.LOCATION_X.name()  + AMessage.unitSplit + ((AUser)agent).locationColumn + 
				AMessage.unitsSplit + AMessage.Units.LOCATION_Y.name()  + AMessage.unitSplit + ((AUser)agent).locationRow + 
				AMessage.unitsSplit + AMessage.Units.TEMPERATURE.name() + AMessage.unitSplit + ((AUser)agent).preferenceTemperature + 
				AMessage.unitsSplit + AMessage.Units.NOISE.name()       + AMessage.unitSplit + ((AUser)agent).preferenceNoiseMax + 
				AMessage.unitsSplit + AMessage.Units.LIGHT.name()       + AMessage.unitSplit + ((AUser)agent).preferenceLight +
				AMessage.unitsSplit + AMessage.Units.WEIGHT.name()      + AMessage.unitSplit + ((AUser)agent).garbageWeight +
				AMessage.unitsSplit + AMessage.Units.VOLUME.name()       + AMessage.unitSplit + ((AUser)agent).garbageVolume
				;
	}
	
	protected String constructSpecialMessage(Messageable agent, MessageType type)
	{
		return null;
	}

	protected void retrieveMyMessage(String theMessage)
	{
		
		String[] send = theMessage.split(AMessage.senderSplit);
		sender = send[0];
		String[] prefs = send[1].split(AMessage.unitsSplit);

		String[] subLocation_x 	= prefs[1].split(AMessage.unitSplit);
		location_x = Integer.parseInt(subLocation_x[1]);
		
		String[] subLocation_y 	= prefs[2].split(AMessage.unitSplit);
		location_y = Integer.parseInt(subLocation_y[1]);
		
		String[] subTemperature = prefs[3].split(AMessage.unitSplit);
		temperature = Integer.parseInt(subTemperature[1]);
		
		String[] subNoise 		= prefs[4].split(AMessage.unitSplit);
		noise = Integer.parseInt(subNoise[1]);
		
		String[] subLight 		= prefs[5].split(AMessage.unitSplit);
		light = Integer.parseInt(subLight[1]);
		
		String[] subWeight 		= prefs[6].split(AMessage.unitSplit);
		garbageWeight = Integer.parseInt(subWeight[1]);

		String[] subVolume 		= prefs[7].split(AMessage.unitSplit);
		garbageVolume = Integer.parseInt(subVolume[1]);
	}
}
